Refactor ExecutionEventRecorder into reusable pieces#2093
Open
Refactor ExecutionEventRecorder into reusable pieces#2093
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the ExecutionEventRecorder into reusable components, enabling the event ring infrastructure to be used for different types of events beyond execution events. The refactoring extracts common event ring ownership and recording logic into new generic classes.
Changes:
- Introduced
OwnedEventRingclass to manage event ring lifecycle (file descriptor, memory mapping, filesystem cleanup) - Introduced
EventRecorderbase class providing a generic C++ interface for event recording with template-based type safety - Refactored
ExecutionEventRecorderto extendEventRecorderand focus on execution-specific flow tracking (block/transaction IDs) - Renamed
ReservedExecEvent<T>toReservedEvent<T>to reflect the generic nature of the infrastructure - Moved tests from execution-specific location to core library tests, adding comprehensive coverage for the new generic interfaces
- Added new test event type
MONAD_TEST_EVENT_VLTfor testing variable-length trailing data handling
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| category/core/event/owned_event_ring.hpp | New RAII class for managing event ring ownership and lifecycle |
| category/core/event/owned_event_ring.cpp | Implementation of OwnedEventRing destructor handling cleanup |
| category/core/event/event_recorder.hpp | New generic C++ interface for type-safe event recording with error handling |
| category/core/event/event_recorder.cpp | Implementation of setup_record_error_event for overflow handling |
| category/execution/ethereum/event/exec_event_recorder.hpp | Refactored to extend EventRecorder, focusing on execution-specific extensions |
| category/execution/ethereum/event/exec_event_recorder.cpp | Simplified to just define global instances, logic moved to base classes |
| cmd/monad/event.cpp | Refactored initialization to use new infrastructure, added init_owned_event_ring helper |
| test/ethereum_test/src/event.cpp | Updated to use OwnedEventRing and new ExecutionEventRecorder constructor |
| test/ethereum_test/src/blockchain_test.cpp | Changed to access event ring through g_exec_event_ring instead of recorder |
| category/execution/ethereum/event/record_block_events.cpp | Updated type from ReservedExecEvent to ReservedEvent |
| category/execution/ethereum/event/record_txn_events.cpp | Updated type from ReservedExecEvent to ReservedEvent |
| category/execution/monad/event/record_consensus_events.cpp | Updated type from ReservedExecEvent to ReservedEvent |
| category/execution/ethereum/event/test/test_exec_event_recorder.cpp | Deleted - tests moved to core library |
| category/core/test/event_recorder.cpp | Added comprehensive tests for new EventRecorder C++ interface |
| category/core/event/test_event_ctypes.h | Added MONAD_TEST_EVENT_VLT for testing |
| category/core/event/test_event_ctypes_metadata.c | Added metadata for new test event type |
| category/core/CMakeLists.txt | Added new source files to build |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4e87d88 to
799a306
Compare
799a306 to
14a66eb
Compare
This factors out the C++ event recording infrastructure (that is part
of exec_event_recorder.{hpp,cpp}) into a "generic" event recorder
class with C++ features. In a subsequent commit, the current execution
event recorder will be changed to use this generic utility class.
The reason for doing this is that currently, there is only a single
recorder (the execution event ring). In other branches, other recorders
exist (e.g., the EVM opcode tracer) which have their own C++ helper
objects. This moves the common functionality to a shared class.
Another thing that happens in this refactoring is that event ring
ownership is made a separate concept from the event ring recorder, and
is managed by the RAII helper "OwnedEventRing." Previously, the
exclusive recorder was also responsible for owning the event ring file.
Separating the two concepts simplifies the initialization code when
there are multiple rings.
This also removes the execution event recorder's unit test test, since the non-trivial functionality lives in the "common" core test now.
14a66eb to
6566b00
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This refactoring is present in other branches that use event rings for other tasks, e.g., the real-time EVM opcode tracer branch uses a new of event ring content type
MONAD_EVENT_CONTENT_TYPE_EVMT, and reuses most of the existing code through this refactoring.This PR is made up of two commits: the first adds new the new infrastructure and the second refactors the existing
ExecutionEventRecorderto use that new infrastructure. The two commit messages describe each change in detail.